import InputArray from './InputArray'
import { getUnRepeatRow } from '../../utils/array'

const InputSelectOptions = (props) => {

  const thisProps = {
    getNewRowData: (value) => {
      return getUnRepeatRow(value, 'label', '选项 ')
    },
    schema: [
      {
        name: 'label',
        label: '选项'
      }
    ]
  }

  return <InputArray
    {...props}
    {...thisProps}
    value={
      props.value ? props.value.map(el => ({
        label: el.label
      })) : []
    }
    onChange={
      newValue => {
        props.onChange(newValue.map(el => ({
          value: el.label,
          label: el.label
        })))
      }
    }
  ></InputArray>
}

InputSelectOptions.propsMap = []

export default InputSelectOptions